package wangwenjun.phase3.executor.completablefuture.demo02;

import lombok.extern.slf4j.Slf4j;
import util.ThreadUtil;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @author ChangLiang
 * @date 2020/6/26
 */
@Slf4j
public class EsService {

    public String searchQueryItems(String keyword) throws InterruptedException {
        int time = ThreadLocalRandom.current().nextInt(1, 5);
        ThreadUtil.sleepForSeconds(time);
        log.info("query item time consumption:{}", time);
        int i = 1/0;
        return keyword + " items";
    }

    public String searchQueryGuides(String keyword) throws InterruptedException {
        int time = ThreadLocalRandom.current().nextInt(1, 5);
        ThreadUtil.sleepForSeconds(time);
        log.info("query guide time consumption:{}", time);
        return keyword + " guides";
    }

    public String getApplications(String keyword) throws InterruptedException {
        int time = ThreadLocalRandom.current().nextInt(1, 5);
        ThreadUtil.sleepForSeconds(time);
        log.info("query applications consumption:{}", time);
        return keyword + " applications";
    }

    public String getAppointItems(String keyword) throws InterruptedException {
        int time = ThreadLocalRandom.current().nextInt(1, 5);
        ThreadUtil.sleepForSeconds(time);
        log.info("query appoint consumption:{}", time);
        return keyword + " appointments";
    }
}
